package com.greyu.ysj.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.greyu.ysj.config.ResultStatus;
import com.greyu.ysj.entity.CbtBallot;
import com.greyu.ysj.entity.CbtDraw;
import com.greyu.ysj.entity.CbtVoteRecharge;
import com.greyu.ysj.mapper.CbtBallotMapper;
import com.greyu.ysj.mapper.CbtDrawMapper;
import com.greyu.ysj.mapper.CbtVoteRechargeMapper;
import com.greyu.ysj.model.ResultModel;
import com.greyu.ysj.service.CbtBallotService;
import com.greyu.ysj.service.CbtDrawService;
import com.greyu.ysj.service.CbtVoteRechargeService;

@Service
@Transactional
public class CbtVoteRechargeServiceImpl implements CbtVoteRechargeService {
	@Autowired
	private CbtVoteRechargeMapper cbtVoteRechargeMapper;


	@Override
	public ResultModel save(CbtVoteRecharge cbtVoteRecharge) {
		try {	
			if ( cbtVoteRecharge.getUserId()==null
					||cbtVoteRecharge.getCount()==null
					||cbtVoteRecharge.getVoteRechargeDate()==null
	        		) {
	            return ResultModel.error(ResultStatus.DATA_NOT_NULL);
	        }
			//insert
	        this.cbtVoteRechargeMapper.insert(cbtVoteRecharge);
		} catch (Exception e) {
			return ResultModel.error(ResultStatus.INSERT_ERROR);
		}
	        return ResultModel.ok(cbtVoteRecharge);
		}


	@Override
	public float selectTotalCountByuserId(int userId) {
		float totalCount=this.cbtVoteRechargeMapper.selectTotalCountByuserId(userId);
		return totalCount;
	}

}




